package com.nbsaas.boot.quartz.utils;

import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;

import java.util.List;

public class ObjectUtils {

    public static <T> List<T> getList(Class<T> clazz, String body) {
        ObjectMapper objectMapper = new ObjectMapper();
        try {
            return objectMapper.readValue(body, new TypeReference<List<T>>() {
            });
        } catch (Exception e) {
            return null;
        }
    }

    public static <T> T getObject(Class<T> clazz, String body) {
        ObjectMapper objectMapper = new ObjectMapper();
        try {
            return objectMapper.readValue(body, clazz);
        } catch (Exception e) {
            return null;
        }
    }

}
